
package fxbattle.fxgui;

import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import fxbattle.client.model.BattleMap;
import javafx.scene.effect.DropShadow;
import fxbattle.client.coms.BattleMapSocketUpdater;
import fxbattle.client.model.Player;
import fxbattle.client.coms.DummyServer;
import java.lang.Thread;

DummyServer.spinOffServerThread();

Thread.sleep(100);
println("Dumy Server Started");

def panelheight = 450;
def panelwidth = 500;
var map_var:BattleMap = new BattleMap();
var updater:BattleMapSocketUpdater = new BattleMapSocketUpdater(map_var, "localhost", DummyServer.DUMMY_SOCKET);
println("Waiting for a player");
var player:Player = updater.requestToPlay("Andy");
println("Got Player {player.getName()}");
updater.retrieveInitialState();
println("Initial State Retrieved. Beginning Listening for Updates");
updater.beginListening();
println("Listening For Updates. Ready to display GUI.");


Stage {
    width : panelwidth
    height : panelheight + 12
    resizable: false
    title : "FxBattle"
    scene : Scene {
        fill : Color.WHITE
        content : [SocketHexMap{
                player: player
                updater: updater
                map : map_var
                effect: DropShadow {
                        offsetX: 10
                        offsetY: 7
                        color: Color.BLACK
                        radius: 25
                    }
            }]
        }
}